package com.zhaoyu.admin.job;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.zhaoyu.admin.feign.wemedia.WemediaFeign;
import com.zhaoyu.admin.service.WemediaNewsAutoScanService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Log4j2
@Component
public class WeMediaNewsAutoScanJob {

    @Autowired
    private WemediaFeign wemediaFeign;

    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @XxlJob("wemediaAutoScanJob")
    public ReturnT<String> hello(String param) throws Exception {
        System.out.println("自媒体文章审核调度任务开始执行....");
        List<Integer> release = wemediaFeign.findRelease();
        if(release != null && !release.isEmpty()){
            for (Integer id : release) {
                wemediaNewsAutoScanService.autoScanByMediaNewsId(id);
            }
        }
        System.out.println("自媒体文章审核调度任务执行结束....");
        return ReturnT.SUCCESS;
    }

}